/*
* jiyan
*/
package com.jiyan.scene.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

import com.jiyan.scene.api.SceneFeignApi;
import com.jiyan.core.exceptions.SceneException;
import com.jiyan.core.exceptions.BaseException;
import com.jiyan.core.entity.Page;
import com.jiyan.scene.entity.Scene;


/**
 * 场景
 * @author jiyan
 */
@Service("sceneSVImpl")
@Slf4j
public class SceneSVImpl {

    @Autowired
    private SceneFeignApi sceneFeignApi;

    /**
     * 加载一个对象Scene
     * @param id * @param code 编码
     * @return Scene
     */
    public Scene load(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return sceneFeignApi.load(id,code);
    }
    /**
     * 加载一个对象Scene 通过id
     * @param id 
     * @return Scene
     */
    public Scene loadById(java.lang.Long id) {
        if(id==null){
            throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return sceneFeignApi.loadById(id);
    }

    /**
     * 加载一个对象Scene 通过code
     * @param code 编码
     * @return Scene
     */
    public Scene loadByCode(java.lang.String code) {
        if(code==null){
            throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        return sceneFeignApi.loadByCode(code);
    }


    /**
     * 删除对象Scene
     * @param id * @param code 编码
     */
    
    public void delete(java.lang.Long id,java.lang.String code) {
        if(id==null&&code==null){
            throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);
        }
        sceneFeignApi.delete(id,code);
    }



    /**
     * 查询Scene分页
     *
     * @param scene  对象
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<Scene>
     */
    public List<Scene> list(Scene scene, int curPage,int pageSize) {
        return sceneFeignApi.list(scene, curPage,pageSize);
    }

    /**
     * 查询Scene分页
     *
     * @param id  * @param code  编码
     * @param curPage 当前页
     * @param pageSize 分页条数
     * @return List<Scene>
     */
    public List<Scene> list(java.lang.Long id,java.lang.String code,int curPage, int pageSize) {
        if (curPage < 0) {
           curPage = 1;
        }

        if (pageSize < 0) {
            pageSize = Page.limit;
        }

        Scene scene=new Scene();
        scene.setId(id);
        scene.setCode(code);

        return sceneFeignApi.list(scene,curPage,pageSize);
    }


    public int count(java.lang.Long id,java.lang.String code) {
        return sceneFeignApi.count(id,code);
    }


    public int count(Scene scene) {
        return sceneFeignApi.count(scene);
    }


    /**
     * 保存
     *
     * @param scene 实体
     * @throws BaseException
     */
    public void save(Scene scene) {
        if(scene==null){ throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        sceneFeignApi.build(scene);
    }

    /**
     * 更新
     *
     * @param scene 实体
     * @throws BaseException
     */
    public void modify(Scene scene) {
        if(scene==null){ throw new SceneException(BaseException.BaseExceptionEnum.Ilegal_Param);}
        sceneFeignApi.modify(scene);
    }

}
